@echo off

set BACKUP_BASE_DIR=G:\backup
set TEXT_DIR=.

for /f "tokens=1,2" %%u in ('date /t') do set d=%%v
::for /f "tokens=1" %%u in ('time /t') do set t=%%u
set t=%TIME%

:: if time begin with " ", replace this with "0"
if "%t:~0,1%"==" " set t=0%t:~1%

::@echo %t%

set TIMESTR=%d:~6,4%-%d:~0,2%-%d:~3,2%_%t:~0,2%-%t:~3,2%
set COPYNAME=%TIMESTR%_%computername%

set BACKUP_DIR=%BACKUP_BASE_DIR%\%TIMESTR%

@echo Backing up to folder %BACKUP_DIR%

if not exist "%BACKUP_BASE_DIR%" mkdir "%BACKUP_BASE_DIR%"
if not exist "%BACKUP_DIR%" mkdir "%BACKUP_DIR%"

@echo on

copy "%TEXT_DIR%\thesis.xml" "%BACKUP_DIR%"
copy "%TEXT_DIR%\thesis.tex" "%BACKUP_DIR%"
copy "%TEXT_DIR%\thesis.pdf" "%BACKUP_DIR%"

@echo off

@echo.  
@echo.
@echo Successfully backed up to folder %BACKUP_DIR%
@echo.
pause
